<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			function objectCopy(obj) {
			  function Fun() { };
			  Fun.prototype = obj;
			  return new Fun()
			}
			
			let person = {
			  name: "yhd",
			  age: 18,
			  friends: ["jack", "tom", "rose"],
			  sayName:function() {
			    console.log(this.name);
			  }
			}
			
			let person1 = objectCopy(person);
			person1.name = "wxb";
			person1.friends.push("lily");
			person1.sayName(); // wxb
			
			let person2 = objectCopy(person);
			person2.name = "gsr";
			person2.friends.push("kobe");
			person2.sayName(); // "gsr"
			
			console.log(person.friends); // ["jack", "tom", "rose", "lily", "kobe"]
		</script>
	</body>
</html>
